package com.ruoyi.project.module.cloudVpe.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.constant.BusinessType;
import com.ruoyi.project.module.cloudVpe.domain.CloudVpe;
import com.ruoyi.project.module.cloudVpe.service.ICloudVpeService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.framework.web.domain.AjaxResult;

/**
 * VPE管理 信息操作处理
 * 
 * @author ruoyi
 * @date 2018-07-23
 */
@Controller
@RequestMapping("/module/cloudVpe")
public class CloudVpeController extends BaseController
{
    private String prefix = "module/cloudVpe";
	
	@Autowired
	private ICloudVpeService cloudVpeService;
	
	@RequiresPermissions("module:cloudVpe:view")
	@GetMapping()
	public String cloudVpe()
	{
	    return prefix + "/cloudVpe";
	}
	
	/**
	 * 查询VPE管理列表
	 */
	@RequiresPermissions("module:cloudVpe:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(CloudVpe cloudVpe)
	{
		startPage();
        List<CloudVpe> list = cloudVpeService.selectCloudVpeList(cloudVpe);
		return getDataTable(list);
	}
	
	
	/**
	 * 查询VPE管理列表
	 */
	@PostMapping("/listBypeId")
	@ResponseBody
	public TableDataInfo listBypeId(Integer peId)
	{
		startPage();
        List<CloudVpe> list = cloudVpeService.selectCloudVPeListbyPe(peId);
		return getDataTable(list);
	}
	
	/**
	 * 新增VPE管理
	 */
	@RequiresPermissions("module:cloudVpe:add")
	@Log(title = "VPE管理", action = BusinessType.INSERT)
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}

	/**
	 * 修改VPE管理
	 */
	@RequiresPermissions("module:cloudVpe:edit")
	@Log(title = "VPE管理", action = BusinessType.UPDATE)
	@GetMapping("/edit/{vpeId}")
	public String edit(@PathVariable("vpeId") Integer vpeId, Model model)
	{
		CloudVpe cloudVpe = cloudVpeService.selectCloudVpeById(vpeId);
		model.addAttribute("cloudVpe", cloudVpe);
	    return prefix + "/edit";
	}
	
	/**
	 * 保存VPE管理
	 */
	@RequiresPermissions("module:cloudVpe:save")
	@Log(title = "VPE管理", action = BusinessType.SAVE)
	@PostMapping("/save")
	@ResponseBody
	public AjaxResult save(CloudVpe cloudVpe)
	{
		if (cloudVpeService.saveCloudVpe(cloudVpe) > 0)
		{
			return success();
		}
		return error();
	}
	
	/**
	 * 删除VPE管理
	 */
	@RequiresPermissions("module:cloudVpe:remove")
	@Log(title = "VPE管理", action = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{
		int rows = cloudVpeService.deleteCloudVpeByIds(ids);
		if (rows > 0)
        {
            return success();
        }
        return error();
	}
	
}
